package com.zhiteng.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiteng.entity.AdjustBill;
import com.zhiteng.mapper.AdjustBillMapper;
import com.zhiteng.service.ReportServcie;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

@Service
public class ReportServcieImpl implements ReportServcie {

	@Autowired
	private AdjustBillMapper adjustBillMapper;

	@Override
	public List<AdjustBill> queryAdjustBySchoolIdAndStatusAndTypeAndQJ(String schoolId, int i, int j, Date startTime3,
			Date endTime3) {
		Example example = new Example(AdjustBill.class);
//		example.orderBy("createDate").asc(); // 升序
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("school_id", schoolId);
		criteria.andEqualTo("type2", j);
		criteria.andEqualTo("status", i);
		criteria.andBetween("adjust_date", startTime3, endTime3);
		return adjustBillMapper.selectByExample(example);
	}

	@Override
	public List<AdjustBill> queryAdjustBySchoolIdAndStatusAndTypeAndQJAndTeacherId(String schoolId, String teacherId,
			int i, int j, Date startTime3, Date endTime3) {
		Example example = new Example(AdjustBill.class);
//		example.orderBy("createDate").asc(); // 升序
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("school_id", schoolId);
		criteria.andEqualTo("teacher_id", teacherId);
		criteria.andEqualTo("type2", j);
		criteria.andEqualTo("status", i);
		criteria.andBetween("adjust_date", startTime3, endTime3);
		return adjustBillMapper.selectByExample(example);
	}

	@Override
	public List<AdjustBill> queryAdjustBySchoolIdAndStatusAndTypeAndQJAndSubject(String schoolId, String subject,
			int i, int j, Date startTime3, Date endTime3) {
		Example example = new Example(AdjustBill.class);
//		example.orderBy("createDate").asc(); // 升序
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("school_id", schoolId);
		criteria.andEqualTo("old_subject", subject);
		criteria.andEqualTo("type2", j);
		criteria.andEqualTo("status", i);
		criteria.andBetween("adjust_date", startTime3, endTime3);
		return adjustBillMapper.selectByExample(example);
	}

	@Override
	public List<AdjustBill> queryAdjustBySchoolIdAndStatusAndTypeAndQJAndPetitionerId(String schoolId, String teacherId,
			int i, int j, Date startTime3, Date endTime3) {
		Example example = new Example(AdjustBill.class);
//		example.orderBy("createDate").asc(); // 升序
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("school_id", schoolId);
		criteria.andEqualTo("petitioner_id", teacherId);
		criteria.andEqualTo("type2", j);
		criteria.andEqualTo("status", i);
		criteria.andBetween("petitioner_date", startTime3, endTime3);
		return adjustBillMapper.selectByExample(example);
	}

}
